<?php
/**
 * Created by PhpStorm.
 * User: DELL-PC
 * Date: 2018/1/24
 * Time: 16:14
 */

namespace Application\UserCenter\Controller;


/**
 * 密码算法
 */
class Password
{
    /**
     * 密码计算规则 $_REQUEST['password'] = md5(verify . md5(password))
     * @param string $password md5(password)
     * @return bool
     */
    public static function isEqual($password)
    {
        // console_debug(strtolower($_REQUEST['verify']) . $password. '='. $_REQUEST['password']);
        return md5(strtolower($_REQUEST['verify']) . $password) === $_REQUEST['password'];
    }

    public static function generate($password = null)
    {
        if(null === $password) $password = $_REQUEST['password'];
        return md5($password);
    }
}